//
//  SISSReminderOfBusinessSettlementShowViewController.m
//  SISSAPP
//
//  Created by 袁应荣 on 2019/7/9.
//  Copyright © 2019 优房网. All rights reserved.
//

#import "SISSReminderOfBusinessSettlementShowViewController.h"
#import "SISSShowView.h"
#import "SISSChooseView.h"
#import "SISSUploadImageShowView.h"
#import "SISSNetworkingManager+Progress.h"
#import "SISSAdditionalNodeModel.h"
#import "SISSProgressWebViewController.h"

@interface SISSReminderOfBusinessSettlementShowViewController ()<SISSChooseViewDelegate>

/// 待办业务
@property (weak, nonatomic) SISSShowView *todoItemShowView;
/// 地点
@property (weak, nonatomic) SISSShowView *titleShowView;
/// 提醒角色
@property (weak, nonatomic) SISSShowView *remindShowView;
/// 补充事项
@property (weak, nonatomic) SISSShowView *additionalTitleView;
///
@property (weak, nonatomic) UIView *addtionalConView;
@property (weak, nonatomic) UILabel *additionalLabel;

@property (weak, nonatomic) SISSUploadImageShowView *uploadImageShowView;

/// 跳转
@property (weak, nonatomic) SISSChooseView *jumpView;

@end

@implementation SISSReminderOfBusinessSettlementShowViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = self.additionalNodeModel.progressTitle;
    
    self.todoItemShowView.rightStr = self.additionalNodeModel.progressTitle;
    self.titleShowView.rightStr = self.additionalNodeModel.title;
    NSArray *roleArr = @[@"只提醒买方", @"只提醒卖方", @"同时提醒买卖方"];
    self.remindShowView.rightStr = roleArr[self.additionalNodeModel.role-1];
    self.additionalLabel.text = self.additionalNodeModel.otherdesc;
    self.uploadImageShowView.imageUrlArr = self.additionalNodeModel.image.mutableCopy;
    
    NSDictionary *nodeDict = @{@"gzwt_tips" : @"办理公证委托注意事项",
                               @"zjjg_tips" : @"办理资金监管相关问题",
                               @"jzdy_tips" : @"取旧证/注销抵押相关问题",
                               @"mmhtgz_tips" : @"办理买卖合同公证",
                               @"ghdj_tips" : @"办理过户登记相关问题",
                               @"jf_tips" : @"入住交接注意事项",
                               @"aj_tips" : @"按揭贷款注意事项",
                               @"fk_tips" : @"签约定房注意事项",
                               @"sl_tips" : @"担保赎楼常见问题",
                               @"dbgs_tips" : @"担保赎楼常见问题",
                               @"dbgspd_tips" : @"担保赎楼常见问题",
                               @"esfjj_tips" : @"入住交接注意事项",
                               @"ajspjg_tips" : @"按揭贷款注意事项",
                               @"zjjgjg_tips" : @"资金监管相关问题",
                               @"sljg_tips" : @"担保赎楼常见问题",
                               @"gljg_tips" : @"办理过户登记相关问题",
                               @"fcpgjg_tips" : @"贷款评估相关问题"};
    self.jumpView.leftStr = nodeDict[self.additionalNodeModel.nodeType];
//    [self requestAdditionalNodeData];
    
}

//- (void)requestAdditionalNodeData {
//    NSString *ahbpId = self.houseProgressModel ? self.houseProgressModel.ahbpId : self.passengerProgressRecordInfoModel.ahbpId;
//    NSString *adbpId = self.passengerProgressModel ? self.passengerProgressModel.adbpId : self.houseProgressRecordInfoModel.adbpId;
//    [kNetworkManager requestAdditionalNodeWithAhbpId:ahbpId adbpId:adbpId success:^(SISSAdditionalNodeModel *additionalNodeModel) {
//        
//        
//        
//    } failed:^(NSError *error) {
//        NSLog(@"%@",error);
//    }];
//}

#pragma mark - SISSChooseViewDelegate
- (void)clickChooseActionWithChooseView:(SISSChooseView *)chooseView {
    
    NSDictionary *urlDict = @{@"gzwt_tips" : @{@"title" : @"公证委托",
                                               @"url" : @"#!/fair"
                                               },
                              @"zjjg_tips" : @{@"title" : @"资金监管相关问题",
                                               @"url" : @"#!/fund/supervision"
                                               },
                              @"jzdy_tips" : @{@"title" : @"取旧证/注销抵押相关问题",
                                               @"url" : @"#!/mortgage/tips"
                                               },
                              @"mmhtgz_tips" : @{@"title" : @"办理买卖合同公证相关问题",
                                                 @"url" : @"#!/deal/fair"
                                                 },
                              @"ghdj_tips" : @{@"title" : @"办理过户登记相关问题",
                                               @"url" : @"#!/deal/transfer"
                                               },
                              @"jf_tips" : @{@"title" : @"入住交接注意事项",
                                             @"url" : @"#!/deal/checkin"
                                             },
                              @"aj_tips" : @{@"title" : @"按揭贷款注意事项",
                                             @"url" : @"#!/deal/loan"
                                             },
                              @"fk_tips" : @{@"title" : @"签约定房注意事项",
                                             @"url" : @"#!/deal/sign"
                                             },
                              @"sl_tips" : @{@"title" : @"担保赎楼常见问题",
                                             @"url" : @"#!/deal/warrant"
                                             },
                              @"dbgs_tips" : @{@"title" : @"担保赎楼常见问题",
                                               @"url" : @"#!/deal/warrant"
                                               },
                              @"dbgspd_tips" : @{@"title" : @"担保赎楼常见问题",
                                                 @"url" : @"#!/deal/warrant"
                                                 },
                              @"esfjj_tips" : @{@"title" : @"入住交接注意事项",
                                                @"url" : @"#!/deal/checkin"
                                                },
                              @"ajspjg_tips" : @{@"title" : @"按揭贷款注意事项",
                                                 @"url" : @"#!/deal/loan"
                                                 },
                              @"zjjgjg_tips" : @{@"title" : @"资金监管相关问题",
                                                 @"url" : @"#!/fund/supervision"
                                                 },
                              @"sljg_tips" : @{@"title" : @"担保赎楼常见问题",
                                               @"url" : @"#!/deal/warrant"
                                               },
                              @"gljg_tips" : @{@"title" : @"办理过户登记相关问题",
                                               @"url" : @"#!/deal/transfer"
                                               },
                              @"fcpgjg_tips" : @{@"title" : @"评估",
                                                 @"url" : @"#!/evaluate"
                                                 }};
    SISSProgressWebViewController *vc = [[SISSProgressWebViewController alloc] init];
    NSDictionary *dict = urlDict[self.additionalNodeModel.nodeType];
    vc.title = dict[@"title"];
    vc.url = dict[@"url"];
    [self.navigationController pushViewController:vc animated:YES];
}

#pragma mark - UI
- (void)setupSubviews {
    [super setupSubviews];
    
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.scrollView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.containerView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    SISSShowView *todoItemShowView = [[SISSShowView alloc] init];
    todoItemShowView.isShowBottomLine = YES;
    todoItemShowView.leftStr = @"办结业务";
    [self.containerView addSubview:todoItemShowView];
    self.todoItemShowView = todoItemShowView;
    
    SISSShowView *titleShowView = [[SISSShowView alloc] init];
    titleShowView.leftStr = @"标题";
    titleShowView.isShowBottomLine = YES;
    [self.containerView addSubview:titleShowView];
    self.titleShowView = titleShowView;
    
    SISSShowView *remindShowView = [[SISSShowView alloc] init];
    remindShowView.isShowBottomLine = YES;
    remindShowView.leftStr = @"提醒角色";
    [self.containerView addSubview:remindShowView];
    self.remindShowView = remindShowView;
    
    SISSShowView *additionalTitleView = [[SISSShowView alloc] init];
    additionalTitleView.leftStr = @"补充事项";
    [self.containerView addSubview:additionalTitleView];
    self.additionalTitleView = additionalTitleView;
    
    UIView *addtionalConView = [UIView new];
    addtionalConView.backgroundColor = [UIColor whiteColor];
    [self.containerView addSubview:addtionalConView];
    self.addtionalConView = addtionalConView;
    
    UILabel *additionalLabel = [UILabel yyr_labelWithText:@"{填写补充事项}" fontSize:16 textColor:MAIN_TEXT_COLOR];
    [addtionalConView addSubview:additionalLabel];
    self.additionalLabel = additionalLabel;
    
    SISSUploadImageShowView *uploadImageShowView = [[SISSUploadImageShowView alloc] init];
    uploadImageShowView.titleStr = @"附件信息";
    [self.containerView addSubview:uploadImageShowView];
    self.uploadImageShowView = uploadImageShowView;
    
    SISSChooseView *jumpView = [[SISSChooseView alloc] init];
    jumpView.isShowBottomLine = YES;
    jumpView.leftStr = @"对应的文字";
    jumpView.delegate = self;
    [self.containerView addSubview:jumpView];
    self.jumpView = jumpView;
    
}

#pragma mark - 约束
- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    [self.todoItemShowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.containerView);
        make.left.right.equalTo(weakSelf.containerView);
        make.height.mas_equalTo(5.5 * globelMargin);
    }];
    
    [self.titleShowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.todoItemShowView.mas_bottom);
        make.left.right.equalTo(weakSelf.containerView);
        make.height.mas_equalTo(5.5 * globelMargin);
    }];
    
    [self.remindShowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.titleShowView.mas_bottom);
        make.left.right.equalTo(weakSelf.containerView);
    }];
    
    [self.additionalTitleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.remindShowView.mas_bottom);
        make.left.right.equalTo(weakSelf.containerView);
        make.height.mas_equalTo(5.5 * globelMargin);
    }];
    
    [self.addtionalConView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.additionalTitleView.mas_bottom);
        make.left.right.equalTo(weakSelf.containerView);
    }];
    [self.additionalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.addtionalConView);
        make.left.equalTo(weakSelf.addtionalConView).offset(2 * globelMargin);
        make.right.bottom.equalTo(weakSelf.addtionalConView).offset(-2 * globelMargin);
    }];
    
    [self.uploadImageShowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.addtionalConView.mas_bottom).offset(2 * globelMargin);
        make.left.right.equalTo(weakSelf.containerView);
    }];
    
    [self.jumpView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.uploadImageShowView.mas_bottom).offset(2 * globelMargin);
        make.left.right.equalTo(weakSelf.containerView);
        make.bottom.equalTo(weakSelf.containerView).offset(-2 * globelMargin);
    }];
    
}

@end
